﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Artemis;

namespace JAWWS
{
    class HPItem : Item
    {
        private int HP;
        private Ball b;
        private bool inInventory;
        public HPItem(MainForm main, float[] pos)
        {
            this.position = pos;
            this.HP = 10;
            this.child = null;
            this.sibling = null;
            this.b = new Ball(main);
            this.TexId = main.TexIDs[4];
            this.LocalTransMatrix = this.IdMatrix;
            type = ItemName.HP_ITEM;
            inInventory = false;
        }
        public int getHP()
        {
            return HP;
        }
        public bool getInInventory()
        {
            return inInventory;
        }
        public void setInInventory(bool arg)
        {
            inInventory = arg;
        }
        public override void apply(Player player)
        {
            if (player.getHealth() <= 100)
            {
                // Caps the HPItem's effectivness so that it never goes over 100 total Health.
                if (player.getHealth() >= 90)
                {
                    player.adjustHealth(100 - player.getHealth());
                }
                else
                {
                    player.adjustHealth(HP);
                }
            }
        }
        public override void draw()
        {
            //Only Draws if not in inventory.
            if (inInventory == false)
            {
                GL.glEnable(GLenum.GL_TEXTURE_2D);
                GL.glBindTexture(GLenum.GL_TEXTURE_2D, b.texID);
                b.draw();
                GL.glDisable(GLenum.GL_TEXTURE_2D);
            }
        }
        public void updateHPItem()
        {
            GL.glPushMatrix();
                GL.glLoadIdentity();
                GL.glTranslatef(position[0], position[1], position[2]);
                GL.glScalef(0.3f, 0.3f, 0.3f);
                GL.glRotatef(75, position[0], position[1], position[2]);
                GL.glGetFloatv(GLenum.GL_MODELVIEW_MATRIX, this.LocalTransMatrix);
            GL.glPopMatrix();
        }
    }
}
